<?php

/*
	[NianCode] (C)2010-2011 NianCode Inc.
	--------------------------------------------
	------------NianCode v1.01beta--------------
	------------powered by nianks~--------------
	--------------------------------------------
	$Id: nc_cache.func.php 2010-6-18 11:22:37 NC nianks $
*/

/*
 * NC_cache..
 */
 function updatacache($cachename = '') {
	global $actions;
	if(!NC_in_array($cachename, $actions)) {
		return 'no avaible cachename!';
	}
	if(empty($cachename)) {
		foreach($actions as $key => $vlue) {
			//if($value === 'NC') {
				if(!file_exists(NC_CACHE_TEM.$key.'.tpl.php') || filesize(NC_CACHE_TEM.$key.'.tpl.php') != filesize(NC_VIEW.$key.'.tpl.php')) {
					if(file_exists(NC_VIEW.$key.'.tpl.php')) {
						$filename = NC_VIEW.$key.'.tpl.php';
						if(!$handle = fopen($filename, 'r')) {
							return 'open failed';
						}
						$contents = temp_preg(fread($handle, filesize($filename)));
						fclose($handle);
						//if(!file_exists(NC_CACHE_TEM.$key.'.tpl.php')) {
							$writename = NC_CACHE_TEM.$key.'.tpl.php';
							if(!$handles = fopen($writename, 'w')) {
								return 'open wirte failed';
							}
							if(fwrite($handles, $contents) === FALSE) {
								echo 'updatacache failed!';
							} else {
							}
							fclose($handles);
						//}
					}
				}
			//}
		}
	}
}
/*
 * NC_cache_category..
 */
 function updatacates() {
 	
}